package com.dayu.web.controller.basic;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dayu.common.annotation.Log;
import com.dayu.common.core.controller.BaseController;
import com.dayu.common.core.domain.AjaxResult;
import com.dayu.common.enums.BusinessType;
import com.dayu.basic.domain.BasicTestTitle;
import com.dayu.basic.service.IBasicTestTitleService;
import com.dayu.common.utils.poi.ExcelUtil;
import com.dayu.common.core.page.TableDataInfo;

/**
 * 验机选项标题Controller
 * 
 * @author HK
 * @date 2021-04-15
 */
@RestController
@RequestMapping("/basic/testTitle")
public class BasicTestTitleController extends BaseController
{
    @Autowired
    private IBasicTestTitleService basicTestTitleService;

    /**
     * 查询验机选项标题列表
     */
    @PreAuthorize("@ss.hasPermi('basic:testTitle:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicTestTitle basicTestTitle)
    {
        startPage();
        List<BasicTestTitle> list = basicTestTitleService.selectBasicTestTitleList(basicTestTitle);
        return getDataTable(list);
    }

    /**
     * 导出验机选项标题列表
     */
    @PreAuthorize("@ss.hasPermi('basic:testTitle:export')")
    @Log(title = "验机选项标题", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BasicTestTitle basicTestTitle)
    {
        List<BasicTestTitle> list = basicTestTitleService.selectBasicTestTitleList(basicTestTitle);
        ExcelUtil<BasicTestTitle> util = new ExcelUtil<BasicTestTitle>(BasicTestTitle.class);
        return util.exportExcel(list, "testTitle");
    }

    /**
     * 获取验机选项标题详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:testTitle:query')")
    @GetMapping(value = "/{titleId}")
    public AjaxResult getInfo(@PathVariable("titleId") Long titleId)
    {
        return AjaxResult.success(basicTestTitleService.selectBasicTestTitleById(titleId));
    }

    /**
     * 新增验机选项标题
     */
    @PreAuthorize("@ss.hasPermi('basic:testTitle:add')")
    @Log(title = "验机选项标题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicTestTitle basicTestTitle)
    {
        return toAjax(basicTestTitleService.insertBasicTestTitle(basicTestTitle));
    }

    /**
     * 修改验机选项标题
     */
    @PreAuthorize("@ss.hasPermi('basic:testTitle:edit')")
    @Log(title = "验机选项标题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicTestTitle basicTestTitle)
    {
        return toAjax(basicTestTitleService.updateBasicTestTitle(basicTestTitle));
    }

    /**
     * 删除验机选项标题
     */
    @PreAuthorize("@ss.hasPermi('basic:testTitle:remove')")
    @Log(title = "验机选项标题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{titleIds}")
    public AjaxResult remove(@PathVariable Long[] titleIds)
    {
        return toAjax(basicTestTitleService.deleteBasicTestTitleByIds(titleIds));
    }
}
